Mercurial > audlegacy-plugins
annotate src/amidi-plug/amidi-plug.c @ 1414:5f892afeb8e1 audacious-plugins-1.4.0-dr2
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
author | Giacomo Lozito <james@develia.org> |
---|---|
date | Mon, 06 Aug 2007 14:01:24 +0200 |
parents | 761e17b23e0c |
children | e11d83ce8d16 |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 * |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2007 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify it |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License as published by the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 * Free Software Foundation; either version 2 of the License, or (at your |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 * option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, but |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * WITHOUT ANY WARRANTY; without even the implied warranty of |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License along |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 * with this program; if not, write to the Free Software Foundation, Inc., |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 #include "amidi-plug.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 |
1097 | 23 InputPlugin *amidiplug_iplist[] = { &amidiplug_ip, NULL }; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1276
diff
changeset
|
25 DECLARE_PLUGIN(amidi-plug, NULL, NULL, amidiplug_iplist, NULL, NULL, NULL, NULL, NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
27 static gboolean amidiplug_detect_by_content( gchar * filename_uri , VFSFile * fp ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 { |
461 | 29 gchar magic_bytes[4]; |
30 gint res = 0; | |
31 | |
32 if ( fp == NULL ) | |
33 return FALSE; | |
34 | |
35 if ( VFS_FREAD( magic_bytes , 1 , 4 , fp ) != 4 ) | |
36 return FALSE; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 |
461 | 38 if ( !strncmp( magic_bytes , "MThd" , 4 ) ) |
39 { | |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
40 DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename_uri ); |
461 | 41 return TRUE; |
42 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 |
461 | 44 if ( !strncmp( magic_bytes , "RIFF" , 4 ) ) |
45 { | |
46 /* skip the four bytes after RIFF, | |
47 then read the next four */ | |
48 if ( VFS_FSEEK( fp , 4 , SEEK_CUR ) != 0 ) | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 return FALSE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 |
461 | 51 if ( VFS_FREAD( magic_bytes , 1 , 4 , fp ) != 4 ) |
52 return FALSE; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
53 |
461 | 54 if ( !strncmp( magic_bytes , "RMID" , 4 ) ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 { |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
56 DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 return TRUE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 } |
461 | 59 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 return FALSE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
65 static gint amidiplug_is_our_file( gchar * filename_uri ) |
461 | 66 { |
67 VFSFile * fp; | |
68 gboolean result = FALSE; | |
69 | |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
70 fp = VFS_FOPEN( filename_uri , "rb" ); |
461 | 71 |
72 if ( fp == NULL ) | |
73 return FALSE; | |
74 | |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
75 result = amidiplug_detect_by_content( filename_uri , fp ); |
461 | 76 VFS_FCLOSE( fp ); |
77 | |
78 return result; | |
79 } | |
80 | |
81 | |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
82 static gint amidiplug_is_our_file_from_vfs( gchar *filename_uri , VFSFile *fp ) |
461 | 83 { |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
84 return amidiplug_detect_by_content( filename_uri , fp ); |
461 | 85 } |
86 | |
87 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
88 static void amidiplug_init( void ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 g_log_set_handler(NULL , G_LOG_LEVEL_WARNING , g_log_default_handler , NULL); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
91 |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
92 amidiplug_gettime_mutex = g_mutex_new(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
93 amidiplug_playing_mutex = g_mutex_new(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
94 amidiplug_pause_cond = g_cond_new(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
95 amidiplug_seekonpause_cond = g_cond_new(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
96 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
97 DEBUGMSG( "init, read configuration\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
98 /* read configuration for amidi-plug */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
99 i_configure_cfg_ap_read(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
100 amidiplug_playing_status = AMIDIPLUG_STOP; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
101 backend.gmodule = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 /* load the backend selected by user */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
103 i_backend_load( amidiplug_cfg_ap.ap_seq_backend ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
106 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 static void amidiplug_cleanup( void ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 i_backend_unload(); /* unload currently loaded backend */ |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
110 |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
111 g_mutex_free(amidiplug_gettime_mutex); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
112 g_mutex_free(amidiplug_playing_mutex); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
113 g_cond_free(amidiplug_pause_cond); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
114 g_cond_free(amidiplug_seekonpause_cond); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
115 amidiplug_pause_cond = NULL; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
116 amidiplug_seekonpause_cond = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
120 static void amidiplug_configure( void ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
121 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
122 /* display the nice config dialog */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 DEBUGMSG( "opening config system\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 i_configure_gui(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
125 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 static void amidiplug_aboutbox( void ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
129 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 i_about_gui(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
132 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
134 static void amidiplug_file_info_box( gchar * filename_uri ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
135 { |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
136 i_fileinfo_gui( filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
139 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
140 static void amidiplug_stop( InputPlayback * playback ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
141 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
142 gboolean is_error = FALSE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 DEBUGMSG( "STOP request at tick: %i\n" , midifile.playing_tick ); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
144 |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
145 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
146 if ( amidiplug_playing_status == AMIDIPLUG_ERR ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
147 is_error = TRUE; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
148 g_mutex_unlock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
149 |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
150 if ( !is_error ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
152 /* if stop wasn't called due to error condition, |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
153 wait until the play thread reach a 'safe state' |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
154 (that is, when amidiplug_play_thread exists) */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
155 while ( !amidiplug_play_thread ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
156 g_usleep( 20000 ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 } |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
158 |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
159 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
160 amidiplug_playing_status = AMIDIPLUG_STOP; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
161 g_cond_signal( amidiplug_pause_cond ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
162 g_mutex_unlock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
163 if ( amidiplug_play_thread ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
165 g_thread_join( amidiplug_play_thread ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
166 amidiplug_play_thread = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
167 } |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
168 if (( backend.autonomous_audio == FALSE ) && ( amidiplug_audio_thread )) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
169 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
170 g_thread_join( amidiplug_audio_thread ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
171 amidiplug_audio_thread = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
172 } |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
173 DEBUGMSG( "STOP activated (play thread joined)\n" ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
175 /* kill the sequencer (while it may have been already killed if coming |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
176 from pause, it's safe to do anyway since it checks for multiple calls) */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 if ( backend.gmodule != NULL ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
178 backend.seq_off(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 /* call seq_stop */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
181 if ( backend.gmodule != NULL ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
182 backend.seq_stop(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
183 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
184 /* close audio if current backend works with output plugin */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
185 if (( backend.gmodule != NULL ) && ( backend.autonomous_audio == FALSE )) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
186 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
187 DEBUGMSG( "STOP activated, closing audio output plugin\n" ); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
188 playback->output->buffer_free(); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
189 playback->output->buffer_free(); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
190 playback->output->close_audio(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
191 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 /* free midi data (if it has not been freed yet) */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 i_midi_free( &midifile ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
195 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
196 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
197 static void amidiplug_pause( InputPlayback * playback, gshort paused ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 if ( paused ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
200 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
201 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
202 if ( amidiplug_playing_status == AMIDIPLUG_SEEK ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
203 { |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
204 DEBUGMSG( "handle SEEK ON PAUSE situation\n" , midifile.playing_tick ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
205 /* uh oh, we have a pending seek; this can happen when a seek |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
206 is requested while playback is paused; wait for that seek to |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
207 be completed before pausing the song again */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
208 while ( amidiplug_playing_status != AMIDIPLUG_PLAY ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
209 g_cond_wait( amidiplug_seekonpause_cond , amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
210 } |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
211 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 DEBUGMSG( "PAUSE request at tick: %i\n" , midifile.playing_tick ); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
213 g_mutex_lock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
214 amidiplug_playing_status = AMIDIPLUG_PAUSE; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
215 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
216 if ( backend.autonomous_audio == FALSE ) |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
217 playback->output->pause(paused); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
218 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
219 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
220 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
221 DEBUGMSG( "PAUSE deactivated, resume playing from tick %i\n" , midifile.playing_tick ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
222 if ( backend.autonomous_audio == FALSE ) |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
223 playback->output->pause(paused); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
224 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
225 amidiplug_playing_status = AMIDIPLUG_PLAY; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
226 g_cond_signal( amidiplug_pause_cond ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
227 /* wait for unpause operation to be completed */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
228 g_cond_wait( amidiplug_pause_cond , amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
229 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
230 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
234 static void amidiplug_seek( InputPlayback * playback, gint time ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
236 DEBUGMSG( "SEEK requested (time %i)...\n" , time ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
237 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
238 midifile.seeking_tick = (gint)((time * 1000000) / midifile.avg_microsec_per_tick); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
239 amidiplug_playing_status = AMIDIPLUG_SEEK; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
240 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
242 if ( backend.autonomous_audio == FALSE ) |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
243 playback->output->flush(time * 1000); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
245 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
247 static gint amidiplug_get_time( InputPlayback *playback ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
249 if ( backend.autonomous_audio == FALSE ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
251 g_mutex_lock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
252 if (( amidiplug_playing_status == AMIDIPLUG_PLAY ) || |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
253 ( amidiplug_playing_status == AMIDIPLUG_PAUSE ) || |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
254 ( amidiplug_playing_status == AMIDIPLUG_SEEK ) || |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
255 (( amidiplug_playing_status == AMIDIPLUG_STOP ) && ( playback->output->buffer_playing() ))) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
256 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
257 g_mutex_unlock( amidiplug_playing_mutex ); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
258 return playback->output->output_time(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
259 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 else if ( amidiplug_playing_status == AMIDIPLUG_STOP ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
262 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 DEBUGMSG( "GETTIME on stopped song, returning -1\n" , time ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 return -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 else /* AMIDIPLUG_ERR */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
267 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
268 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
269 DEBUGMSG( "GETTIME on halted song (an error occurred?), returning -1 and stopping the player\n" ); |
1020
fe9ffc829b5f
[svn] - amidi-plug works again (uses auddrct.h in place of the deprecated beepctrl.h)
giacomo
parents:
561
diff
changeset
|
270 audacious_drct_stop(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 return -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
276 gint pt; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
277 g_mutex_lock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
278 if (( amidiplug_playing_status == AMIDIPLUG_PLAY ) || |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
279 ( amidiplug_playing_status == AMIDIPLUG_PAUSE ) || |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
280 ( amidiplug_playing_status == AMIDIPLUG_SEEK )) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
282 g_mutex_unlock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
283 g_mutex_lock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
284 pt = midifile.playing_tick; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
285 g_mutex_unlock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
286 return (gint)((pt * midifile.avg_microsec_per_tick) / 1000); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 else if ( amidiplug_playing_status == AMIDIPLUG_STOP ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
290 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
291 DEBUGMSG( "GETTIME on stopped song, returning -1\n" , time ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
292 return -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
293 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 else /* AMIDIPLUG_ERR */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 { |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
296 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
297 DEBUGMSG( "GETTIME on halted song (an error occurred?), returning -1 and stopping the player\n" , time ); |
1020
fe9ffc829b5f
[svn] - amidi-plug works again (uses auddrct.h in place of the deprecated beepctrl.h)
giacomo
parents:
561
diff
changeset
|
298 audacious_drct_stop(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 return -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
300 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
301 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
304 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
305 static gint amidiplug_get_volume( gint * l_p , gint * r_p ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 if ( backend.autonomous_audio == TRUE ) |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
308 { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 backend.audio_volume_get( l_p , r_p ); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
310 return 1; |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
311 } |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
312 return 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
316 static gint amidiplug_set_volume( gint l , gint r ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 if ( backend.autonomous_audio == TRUE ) |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
319 { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
320 backend.audio_volume_set( l , r ); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
321 return 1; |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
322 } |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
323 return 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
327 static void amidiplug_get_song_info( gchar * filename_uri , gchar ** title , gint * length ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
328 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 /* song title, get it from the filename */ |
1276
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
330 gchar * filename = g_filename_from_uri( filename_uri , NULL , NULL ); |
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
331 if ( !filename ) filename = g_strdup( filename_uri ); |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
332 *title = G_PATH_GET_BASENAME(filename_uri); |
1276
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
333 g_free( filename ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
334 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
335 /* sure, it's possible to calculate the length of a MIDI file anytime, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
336 but the file must be entirely parsed to calculate it; this could |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
337 lead to a bit of performance loss, so let the user decide here */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
338 if ( amidiplug_cfg_ap.ap_opts_length_precalc ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 /* let's calculate the midi length, using this nice helper function that |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 will return 0 if a problem occurs and the length can't be calculated */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
342 midifile_t mf; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
343 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
344 if ( i_midi_parse_from_filename( filename_uri , &mf ) ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 *length = (gint)(mf.length / 1000); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
346 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
347 *length = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
348 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
349 i_midi_free( &mf ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 } |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
351 else |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
352 *length = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
354 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
355 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
356 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
358 static void amidiplug_play( InputPlayback * playback ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
359 { |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
360 gchar * filename_uri = playback->filename; |
1276
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
361 gchar * filename = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
362 gint port_count = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
363 gint au_samplerate = -1, au_bitdepth = -1, au_channels = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
364 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 if ( backend.gmodule == NULL ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
366 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
367 g_warning( "No sequencer backend selected\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
368 i_message_gui( _("AMIDI-Plug - warning") , |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
369 _("No sequencer backend has been selected!\nPlease configure AMIDI-Plug before playing.") , |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
370 AMIDIPLUG_MESSAGE_WARN , NULL , TRUE ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
371 amidiplug_playing_status = AMIDIPLUG_ERR; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
372 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
373 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
375 /* get information about audio from backend, if available */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
376 backend.audio_info_get( &au_channels , &au_bitdepth , &au_samplerate ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 DEBUGMSG( "PLAY requested, audio details: channels -> %i , bitdepth -> %i , samplerate -> %i\n" , |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
378 au_channels , au_bitdepth , au_samplerate ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
379 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
380 if ( backend.autonomous_audio == FALSE ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
381 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
382 DEBUGMSG( "PLAY requested, opening audio output plugin\n" ); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
383 playback->output->open_audio( FMT_S16_NE , au_samplerate , au_channels ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
384 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
385 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
386 DEBUGMSG( "PLAY requested, midifile init\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
387 /* midifile init */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
388 i_midi_init( &midifile ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
389 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
390 /* get the number of selected ports */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
391 port_count = backend.seq_get_port_count(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
392 if ( port_count < 1 ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
393 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
394 g_warning( "No ports selected\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
395 amidiplug_playing_status = AMIDIPLUG_ERR; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
396 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
397 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
398 |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
399 DEBUGMSG( "PLAY requested, opening file: %s\n" , filename_uri ); |
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
400 midifile.file_pointer = VFS_FOPEN( filename_uri , "rb" ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 if (!midifile.file_pointer) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 { |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
403 g_warning( "Cannot open %s\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 amidiplug_playing_status = AMIDIPLUG_ERR; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
405 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
406 } |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
407 midifile.file_name = filename_uri; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
409 switch( i_midi_file_read_id( &midifile ) ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 case MAKE_ID('R', 'I', 'F', 'F'): |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 DEBUGMSG( "PLAY requested, RIFF chunk found, processing...\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
414 /* read riff chunk */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 if ( !i_midi_file_parse_riff( &midifile ) ) |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
416 WARNANDBREAKANDPLAYERR( "%s: invalid file format (riff parser)\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
417 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 /* if that was read correctly, go ahead and read smf data */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
419 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 case MAKE_ID('M', 'T', 'h', 'd'): |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
423 DEBUGMSG( "PLAY requested, MThd chunk found, processing...\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
424 if ( !i_midi_file_parse_smf( &midifile , port_count ) ) |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
425 WARNANDBREAKANDPLAYERR( "%s: invalid file format (smf parser)\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
427 if ( midifile.time_division < 1 ) |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
428 WARNANDBREAKANDPLAYERR( "%s: invalid time division (%i)\n" , filename_uri , midifile.time_division ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
430 DEBUGMSG( "PLAY requested, setting ppq and tempo...\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
431 /* fill midifile.ppq and midifile.tempo using time_division */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
432 if ( !i_midi_setget_tempo( &midifile ) ) |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
433 WARNANDBREAKANDPLAYERR( "%s: invalid values while setting ppq and tempo\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
435 DEBUGMSG( "PLAY requested, sequencer start\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
436 /* sequencer start */ |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
437 if ( !backend.seq_start( filename_uri ) ) |
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
438 WARNANDBREAKANDPLAYERR( "%s: problem with seq_start, play aborted\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
439 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
440 DEBUGMSG( "PLAY requested, sequencer on\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
441 /* sequencer on */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
442 if ( !backend.seq_on() ) |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
443 WARNANDBREAKANDPLAYERR( "%s: problem with seq_on, play aborted\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
444 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
445 DEBUGMSG( "PLAY requested, setting sequencer queue tempo...\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
446 /* set sequencer queue tempo using ppq and tempo (call only after i_midi_setget_tempo) */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
447 if ( !backend.seq_queue_tempo( midifile.current_tempo , midifile.ppq ) ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
448 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
449 backend.seq_off(); /* kill the sequencer */ |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
450 WARNANDBREAKANDPLAYERR( "%s: ALSA queue problem, play aborted\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
451 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
452 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
453 /* fill midifile.length, keeping in count tempo-changes */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 i_midi_setget_length( &midifile ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
455 DEBUGMSG( "PLAY requested, song length calculated: %i msec\n" , (gint)(midifile.length / 1000) ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
456 |
1276
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
457 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
458 /* our length is in microseconds, but the player wants milliseconds */ |
1276
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
459 filename = g_filename_from_uri( filename_uri , NULL , NULL ); |
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
460 if ( !filename ) filename = g_strdup( filename_uri ); |
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
461 amidiplug_ip.set_info( G_PATH_GET_BASENAME(filename) , |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
462 (gint)(midifile.length / 1000) , |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
463 au_bitdepth * au_samplerate * au_channels / 8 , |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
464 au_samplerate , au_channels ); |
1276
504c0dc36c0a
further improvements for amidi-plug with URIs
Giacomo Lozito <james@develia.org>
parents:
1275
diff
changeset
|
465 g_free( filename ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
466 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
467 /* done with file */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
468 VFS_FCLOSE( midifile.file_pointer ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
469 midifile.file_pointer = NULL; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
470 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
471 /* play play play! */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 DEBUGMSG( "PLAY requested, starting play thread\n" ); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
473 g_mutex_lock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
474 amidiplug_playing_status = AMIDIPLUG_PLAY; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
475 g_mutex_unlock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
476 amidiplug_play_thread = g_thread_self(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
477 amidiplug_play_loop(playback); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
478 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
479 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
480 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
481 default: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
482 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
483 amidiplug_playing_status = AMIDIPLUG_ERR; |
1275
b839faa693e2
updated amidi-plug to handle URIs in fileinfo and all-over in code
Giacomo Lozito <james@develia.org>
parents:
1112
diff
changeset
|
484 g_warning( "%s is not a Standard MIDI File\n" , filename_uri ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
485 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
486 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
487 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
488 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
489 if ( midifile.file_pointer ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
490 { |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
491 /* done with file */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
492 VFS_FCLOSE( midifile.file_pointer ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
493 midifile.file_pointer = NULL; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
494 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
495 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
496 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
497 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
498 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
499 gpointer amidiplug_play_loop( gpointer arg ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
500 { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
501 InputPlayback *playback = arg; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
502 gint j = 0; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
503 gboolean rewind = TRUE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
504 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
505 if ( rewind ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
506 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
507 /* initialize current position in each track */ |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
508 for (j = 0; j < midifile.num_tracks; ++j) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
509 midifile.tracks[j].current_event = midifile.tracks[j].first_event; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
510 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
511 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
512 if ( backend.autonomous_audio == FALSE ) |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
513 amidiplug_audio_thread = g_thread_create(amidiplug_audio_loop, playback, TRUE, NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
514 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
515 /* queue start */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
516 backend.seq_queue_start(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
517 /* common settings for all our events */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
518 backend.seq_event_init(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
519 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
520 DEBUGMSG( "PLAY thread, start the play loop\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
521 for (;;) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
522 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
523 midievent_t * event = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
524 midifile_track_t * event_track = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
525 gint i, min_tick = midifile.max_tick + 1; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
526 |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
527 /* check if the song has been paused/seeked/stopped */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
528 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
529 if ( amidiplug_playing_status != AMIDIPLUG_PLAY ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
530 { |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
531 DEBUGMSG( "PLAY thread, PAUSE/SEEK/STOP requested, handle in play loop\n" ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
532 if ( amidiplug_playing_status == AMIDIPLUG_PAUSE ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
533 { |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
534 DEBUGMSG( "PLAY thread, PAUSE requested, shut notes and make the play loop wait\n" ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
535 backend.seq_event_allnoteoff( midifile.playing_tick ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
536 backend.seq_queue_stop(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
537 while (( amidiplug_playing_status != AMIDIPLUG_PLAY ) && |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
538 ( amidiplug_playing_status != AMIDIPLUG_STOP )) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
539 g_cond_wait( amidiplug_pause_cond , amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
540 DEBUGMSG( "PLAY thread, UNPAUSE requested, resume playing\n" ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
541 g_mutex_lock( amidiplug_gettime_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
542 midifile.skip_offset = midifile.playing_tick; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
543 g_mutex_unlock( amidiplug_gettime_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
544 if ( backend.autonomous_audio == FALSE ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
545 amidiplug_audio_thread = g_thread_create(amidiplug_audio_loop, playback, TRUE, NULL); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
546 backend.seq_queue_start(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
547 g_cond_signal( amidiplug_pause_cond ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
548 } |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
549 if ( amidiplug_playing_status == AMIDIPLUG_SEEK ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
550 { |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
551 backend.seq_event_allnoteoff( midifile.playing_tick ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
552 backend.seq_queue_stop(); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
553 amidiplug_skipto( midifile.seeking_tick ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
554 midifile.seeking_tick = -1; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
555 amidiplug_playing_status = AMIDIPLUG_PLAY; |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
556 g_cond_signal( amidiplug_seekonpause_cond ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
557 } |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
558 if ( amidiplug_playing_status == AMIDIPLUG_STOP ) |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
559 { |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
560 DEBUGMSG( "PLAY thread, STOP requested, stopping...\n" ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
561 g_mutex_unlock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
562 break; /* exit from the for (;;) loop */ |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
563 } |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
564 } |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
565 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
566 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
567 /* search next event */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
568 for (i = 0; i < midifile.num_tracks; ++i) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
569 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
570 midifile_track_t * track = &midifile.tracks[i]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
571 midievent_t * e2 = track->current_event; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
572 if (( e2 ) && ( e2->tick < min_tick )) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
573 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
574 min_tick = e2->tick; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
575 event = e2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
576 event_track = track; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
577 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
578 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
579 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
580 if (!event) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
581 break; /* end of song reached */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
582 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
583 /* advance pointer to next event */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
584 event_track->current_event = event->next; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
585 /* consider the midifile.skip_offset */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
586 event->tick_real = event->tick - midifile.skip_offset; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
587 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
588 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
589 switch (event->type) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
590 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
591 case SND_SEQ_EVENT_NOTEON: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
592 backend.seq_event_noteon( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
593 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
594 case SND_SEQ_EVENT_NOTEOFF: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
595 backend.seq_event_noteoff( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
596 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
597 case SND_SEQ_EVENT_KEYPRESS: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
598 backend.seq_event_keypress( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
599 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
600 case SND_SEQ_EVENT_CONTROLLER: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
601 backend.seq_event_controller( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
602 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
603 case SND_SEQ_EVENT_PGMCHANGE: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
604 backend.seq_event_pgmchange( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
605 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
606 case SND_SEQ_EVENT_CHANPRESS: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
607 backend.seq_event_chanpress( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
608 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
609 case SND_SEQ_EVENT_PITCHBEND: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
610 backend.seq_event_pitchbend( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
611 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
612 case SND_SEQ_EVENT_SYSEX: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
613 backend.seq_event_sysex( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
614 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
615 case SND_SEQ_EVENT_TEMPO: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
616 backend.seq_event_tempo( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
617 DEBUGMSG( "PLAY thread, processing tempo event with value %i on tick %i\n" , |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
618 event->data.tempo , event->tick ); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
619 g_mutex_lock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
620 midifile.current_tempo = event->data.tempo; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
621 g_mutex_unlock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
622 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
623 case SND_SEQ_EVENT_META_TEXT: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
624 /* do nothing */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
625 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
626 case SND_SEQ_EVENT_META_LYRIC: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
627 /* do nothing */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
628 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
629 default: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
630 DEBUGMSG( "PLAY thread, encountered invalid event type %i\n" , event->type ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
631 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
632 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
633 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
634 g_mutex_lock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
635 midifile.playing_tick = event->tick; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
636 g_mutex_unlock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
637 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
638 if ( backend.autonomous_audio == TRUE ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
639 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
640 /* these backends deal with audio production themselves (i.e. ALSA) */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
641 backend.seq_output( NULL , NULL ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
642 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
643 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
644 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
645 backend.seq_output_shut( midifile.max_tick , midifile.skip_offset ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
646 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
647 g_mutex_lock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
648 if ( amidiplug_playing_status != AMIDIPLUG_PAUSE ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
649 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
650 amidiplug_playing_status = AMIDIPLUG_STOP; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
651 DEBUGMSG( "PLAY thread, song stopped/ended\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
652 } |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
653 g_mutex_unlock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
654 return NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
655 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
656 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
657 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
658 /* amidigplug_skipto: re-do all events that influence the playing of our |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
659 midi file; re-do them using a time-tick of 0, so they are processed |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
660 istantaneously and proceed this way until the playing_tick is reached; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
661 also obtain the correct skip_offset from the playing_tick */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
662 void amidiplug_skipto( gint playing_tick ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
663 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
664 gint i; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
665 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
666 /* this check is always made, for safety*/ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
667 if ( playing_tick >= midifile.max_tick ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
668 playing_tick = midifile.max_tick - 1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
669 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
670 /* initialize current position in each track */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
671 for (i = 0; i < midifile.num_tracks; ++i) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
672 midifile.tracks[i].current_event = midifile.tracks[i].first_event; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
673 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
674 /* common settings for all our events */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
675 backend.seq_event_init(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
676 backend.seq_queue_start(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
677 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
678 DEBUGMSG( "SKIPTO request, starting skipto loop\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
679 for (;;) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
680 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
681 midievent_t * event = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
682 midifile_track_t * event_track = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
683 gint i, min_tick = midifile.max_tick + 1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
684 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
685 /* search next event */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
686 for (i = 0; i < midifile.num_tracks; ++i) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
687 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
688 midifile_track_t * track = &midifile.tracks[i]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
689 midievent_t * e2 = track->current_event; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
690 if (( e2 ) && ( e2->tick < min_tick )) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
691 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
692 min_tick = e2->tick; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
693 event = e2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
694 event_track = track; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
695 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
696 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
697 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
698 /* unlikely here... unless very strange MIDI files are played :) */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
699 if (!event) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
700 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
701 DEBUGMSG( "SKIPTO request, reached the last event but not the requested tick (!)\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
702 break; /* end of song reached */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
703 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
704 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
705 /* reached the requested tick, job done */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
706 if ( event->tick >= playing_tick ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
707 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
708 DEBUGMSG( "SKIPTO request, reached the requested tick, exiting from skipto loop\n" ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
709 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
710 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
711 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
712 /* advance pointer to next event */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
713 event_track->current_event = event->next; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
714 /* set the time tick to 0 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
715 event->tick_real = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
716 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
717 switch (event->type) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
718 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
719 /* do nothing for these |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
720 case SND_SEQ_EVENT_NOTEON: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
721 case SND_SEQ_EVENT_NOTEOFF: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
722 case SND_SEQ_EVENT_KEYPRESS: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
723 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
724 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
725 } */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
726 case SND_SEQ_EVENT_CONTROLLER: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
727 backend.seq_event_controller( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
728 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
729 case SND_SEQ_EVENT_PGMCHANGE: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
730 backend.seq_event_pgmchange( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
731 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
732 case SND_SEQ_EVENT_CHANPRESS: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
733 backend.seq_event_chanpress( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
734 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
735 case SND_SEQ_EVENT_PITCHBEND: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
736 backend.seq_event_pitchbend( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
737 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
738 case SND_SEQ_EVENT_SYSEX: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
739 backend.seq_event_sysex( event ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
740 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
741 case SND_SEQ_EVENT_TEMPO: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
742 backend.seq_event_tempo( event ); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
743 g_mutex_lock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
744 midifile.current_tempo = event->data.tempo; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
745 g_mutex_unlock( amidiplug_gettime_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
746 break; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
747 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
748 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
749 if ( backend.autonomous_audio == TRUE ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
750 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
751 /* these backends deal with audio production themselves (i.e. ALSA) */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
752 backend.seq_output( NULL , NULL ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
753 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
754 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
755 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
756 midifile.skip_offset = playing_tick; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
757 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
758 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
759 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
760 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
761 |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
762 gpointer amidiplug_audio_loop( gpointer arg ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
763 { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
764 InputPlayback *playback = arg; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
765 gboolean going = 1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
766 gpointer buffer = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
767 gint buffer_size = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
768 while ( going ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
769 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
770 if ( backend.seq_output( &buffer , &buffer_size ) ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
771 { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
772 while( ( playback->output->buffer_free() < buffer_size ) && ( going == TRUE ) ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
773 G_USLEEP(10000); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
774 produce_audio( playback->output->written_time() , |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
775 FMT_S16_NE , 2 , buffer_size , buffer , &going ); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
776 } |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
777 g_mutex_lock( amidiplug_playing_mutex ); |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
778 if (( amidiplug_playing_status != AMIDIPLUG_PLAY ) && |
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
779 ( amidiplug_playing_status != AMIDIPLUG_SEEK )) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
780 going = FALSE; |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
781 g_mutex_unlock( amidiplug_playing_mutex ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
782 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
783 if ( buffer != NULL ) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
784 g_free( buffer ); |
1414
5f892afeb8e1
- amidi-plug 0.8 beta1; support for gthread and v3 plugin system; needs testing and refinements
Giacomo Lozito <james@develia.org>
parents:
1395
diff
changeset
|
785 return NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
786 } |