Fixes for alsa device reservation
[jack2.git] / windows / winmme / JackWinMMEPort.cpp
blob13ec2302badc484a2989774bd763be129c991498
1 /*
2 Copyright (C) 2011 Devin Anderson
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <memory>
21 #include <stdexcept>
22 #include <stdio.h>
24 #include "JackWinMMEPort.h"
25 #include "JackError.h"
27 using Jack::JackWinMMEPort;
29 ///////////////////////////////////////////////////////////////////////////////
30 // Class
31 ///////////////////////////////////////////////////////////////////////////////
33 JackWinMMEPort::JackWinMMEPort()
36 JackWinMMEPort::~JackWinMMEPort()
39 const char *
40 JackWinMMEPort::GetAlias()
42 return alias;
45 const char *
46 JackWinMMEPort::GetName()
48 return name;
51 void
52 JackWinMMEPort::GetOSErrorString(LPTSTR text)
54 DWORD error = GetLastError();
55 if (! FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,
56 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), text,
57 MAXERRORLENGTH, NULL)) {
58 snprintf(text, MAXERRORLENGTH, "Unknown OS error code '%d'", error);
62 void
63 JackWinMMEPort::WriteOSError(const char *jack_func, const char *os_func)
65 char error_message[MAXERRORLENGTH];
66 GetOSErrorString(error_message);
67 jack_error("%s - %s: %s", jack_func, os_func, error_message);