1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2019 Joël Krähemann
3  *
4  * This file is part of GSequencer.
5  *
6  * GSequencer is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSequencer is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSequencer.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __AGS_PLAYBACK_H__
21 #define __AGS_PLAYBACK_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <ags/libags.h>
27 
28 #include <ags/audio/ags_sound_enums.h>
29 #include <ags/audio/ags_recall_id.h>
30 
31 G_BEGIN_DECLS
32 
33 #define AGS_TYPE_PLAYBACK                (ags_playback_get_type())
34 #define AGS_PLAYBACK(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_PLAYBACK, AgsPlayback))
35 #define AGS_PLAYBACK_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST(class, AGS_TYPE_PLAYBACK, AgsPlayback))
36 #define AGS_IS_PLAYBACK(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_PLAYBACK))
37 #define AGS_IS_PLAYBACK_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_PLAYBACK))
38 #define AGS_PLAYBACK_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS(obj, AGS_TYPE_PLAYBACK, AgsPlaybackClass))
39 
40 #define AGS_PLAYBACK_GET_OBJ_MUTEX(obj) (&(((AgsPlayback *) obj)->obj_mutex))
41 
42 typedef struct _AgsPlayback AgsPlayback;
43 typedef struct _AgsPlaybackClass AgsPlaybackClass;
44 
45 /**
46  * AgsPlaybackFlags:
47  * @AGS_PLAYBACK_CONNECTED: indicates the playback was connected by calling #AgsConnectable::connect()
48  * @AGS_PLAYBACK_SINGLE_THREADED: single threaded
49  * @AGS_PLAYBACK_SUPER_THREADED_CHANNEL: super threaded channel
50  *
51  * Enum values to control the behavior or indicate internal state of #AgsPlayback by
52  * enable/disable as flags.
53  */
54 typedef enum{
55   AGS_PLAYBACK_CONNECTED                    = 1,
56   AGS_PLAYBACK_SINGLE_THREADED              = 1 <<  1,
57   AGS_PLAYBACK_SUPER_THREADED_CHANNEL       = 1 <<  2,
58 }AgsPlaybackFlags;
59 
60 struct _AgsPlayback
61 {
62   GObject gobject;
63 
64   guint flags;
65 
66   GRecMutex obj_mutex;
67 
68   GObject *playback_domain;
69 
70   GObject *channel;
71   guint audio_channel;
72 
73   GObject *play_note;
74 
75   AgsThread **channel_thread;
76 
77   AgsRecallID **recall_id;
78 };
79 
80 struct _AgsPlaybackClass
81 {
82   GObjectClass gobject;
83 };
84 
85 GType ags_playback_get_type();
86 
87 gboolean ags_playback_test_flags(AgsPlayback *playback, guint flags);
88 void ags_playback_set_flags(AgsPlayback *playback, guint flags);
89 void ags_playback_unset_flags(AgsPlayback *playback, guint flags);
90 
91 /* get and set */
92 void ags_playback_set_channel_thread(AgsPlayback *playback,
93 				     AgsThread *thread,
94 				     gint sound_scope);
95 AgsThread* ags_playback_get_channel_thread(AgsPlayback *playback,
96 					   gint sound_scope);
97 
98 void ags_playback_set_recall_id(AgsPlayback *playback,
99 				AgsRecallID *recall_id,
100 				gint sound_scope);
101 AgsRecallID* ags_playback_get_recall_id(AgsPlayback *playback,
102 					gint sound_scope);
103 
104 /* find */
105 AgsPlayback* ags_playback_find_channel(GList *playback,
106 				       GObject *channel);
107 
108 /* instance */
109 AgsPlayback* ags_playback_new(GObject *channel);
110 
111 G_END_DECLS
112 
113 #endif /*__AGS_PLAYBACK_H__*/
114